package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.mappers.QuestionMapper;
import com.tanhua.model.domain.Question;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class QuestionApiImpl implements QuestionApi {


    @Autowired
    private QuestionMapper questionMapper;

    //根据id查询Question，陌生人问题
    public Question queryQuestion(Long id) {
        QueryWrapper<Question> qw = new QueryWrapper<>();
        qw.eq("user_id", id);
        Question question = questionMapper.selectOne(qw);
        return question;
    }

    // //保存陌生人问题到数据库
    @Override
    public void saveQuestion(Question question) {
        questionMapper.insert(question);
    }

    // //更新数据库的陌生人问题
    @Override
    public void updateQuestion(Question question) {
        questionMapper.updateById(question);
    }
}
